#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QObject>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QMessageBox>
#include <QLineEdit>
#include <QContextMenuEvent>
#include <QGroupBox>
#include <QDateTime>
#include <QGuiApplication>
#include <QScreen>
#include <QApplication>


#include "videoreceiver.h"
#include "rightclickmenu.h"
#include "videowindow.h"
#include "settingfunc.h"
#include "displayer.h"
#include "maincontrol.h"

class MainWindow : public QObject
{
    Q_OBJECT
public:
    explicit MainWindow(QObject *parent = nullptr);
    ~MainWindow();

    void initDisplayer();

    void initSave(QVector<WINDOW_CONFIG>& configs, int validNum);   //初始化数据存储功能

public slots:
    void onOpenSettingForm(); //打开设置界面

    void onResetConfig(int displayerID, int videoID); //重置配置文件

    //param:显示器编号，视频编号，视频源名称，ip， 端口， 分辨率
    void onDisplayCfgChanged(quint8 displayNum, WINDOW_CONFIG config);

    void onSaveData(int videoID, const QByteArray &data, QString ipSrc, quint16 portSrc);  //存储响应

signals:
    void sigSendToSave(QString ipSrc, quint16 port, const QByteArray &data);

private:
    QList<QScreen*> m_screens; //存储四个显示器的list
    QList<Displayer*> m_screenContainers; // 每个显示器的容器

    QList<QGridLayout*> m_gridLayouts; //存储所有显示器的网格布局
    int m_currentLayout;  //网格布局模式

    SettingFunc settingFunc;  //设置界面对象
    MyConfig saveWindowConfigs; //保存配置对象
    QVector<WINDOW_CONFIG> m_windowConfig_1 = {WINDOW_CONFIG{},WINDOW_CONFIG{}, WINDOW_CONFIG{}, WINDOW_CONFIG{}};
    QVector<WINDOW_CONFIG> m_windowConfig_2 = {WINDOW_CONFIG{},WINDOW_CONFIG{}, WINDOW_CONFIG{}, WINDOW_CONFIG{}};
    QVector<WINDOW_CONFIG> m_windowConfig_3 =  {WINDOW_CONFIG{},WINDOW_CONFIG{}, WINDOW_CONFIG{}, WINDOW_CONFIG{}};
    QVector<WINDOW_CONFIG> m_windowConfig_4 =  {WINDOW_CONFIG{},WINDOW_CONFIG{}, WINDOW_CONFIG{}, WINDOW_CONFIG{}};
    QVector<WINDOW_CONFIG> m_windowConfigs = {}; //设置总配置

    MainControl *saveControl; //存储控制对象
};

#endif // MAINWINDOW_H    
